package cn.sjxy.ssm.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.*;
import cn.sjxy.ssm.dao.DepartmentMapper;
import cn.sjxy.ssm.domain.Department;
@Service
@Transactional(isolation = Isolation.DEFAULT,readOnly = true)
public class DepartmentService {
    @Autowired
	private DepartmentMapper departmentDao;

	public DepartmentMapper getDepartmentDao() {
		return departmentDao;
	}

	public void setDepartmentDao(DepartmentMapper departmentDao) {
		this.departmentDao = departmentDao;
	}
    @Transactional(readOnly = false,propagation = Propagation.REQUIRED)
    //保存部门信息
	public void addDept(Department dept) {
		  departmentDao.save(dept);
	}
	//部门号查询部门
	public Department findDeptById(String deptId) {
		return departmentDao.findById(deptId);
	}
	//查询所有部门信息
	public List<Department> findAllDepts(){
		return departmentDao.findAll();
	}
}
